package com.app.view.component.room.seat 
{
	import com.peachcastle.debug.Log;
	
	/**
	 * ...
	 * @author kevin
	 */
	public class PaijiuType 
	{
		public static const TYPES:Array = [
											{'4221': '至尊寶' }, 
											{ '6666': '雙天' }, { '1111': '雙地' }, 
											{ '4444': '孖人' }, { '3131': '孖鵝' }, { '5555': '孖梅' },
											{'222222': '孖長' }, { '2222': '孖板凳' }, { '6565': '孖斧頭' },
											{'6464': '孖紅頭' }, { '6161': '孖高腳' }, { '5151': '孖零霖' },
											
											{'6354': '雜九' }, { '6253': '雜八' }, { '5243': '雜七' },
											{'4132': '雜五' }, 
											
											{ '6663': '天王' }, { '6654': '天王' }, 
											{'6311': '地王' }, { '5411': '地王' }, 
											{ '6662': '天槓' }, { '6653': '天槓' }, { '6644': '天槓' },
											{ '6211': '地槓' }, { '5311': '地槓' }, { '4411': '地槓' },
											
											{'6652': '天高九' }, { '6111': '地高九' }
										  ];
		
		public function PaijiuType() 
		{
			
		}
		
		public static function judgeType(pais:Array):Array
		{
			var f:String = String(pais[0]) + String(pais[1]); 
			var s:String = String(pais[1]) + String(pais[0]);
			for (var i:String in TYPES)
			{
				for (var j:String in TYPES[i])
				{
					if (j == f || j == s)
					{
						return [i, TYPES[i][j]];
					}
				}
			}
			
			var n:int = 0;
			var af:Array = f.split("");
			for (var k:int = 0; k < af.length; k++) 
			{
				n += int(af[k]);
			}
			
			return [-1, String(n % 10)];
		}
		
		public static function pk(a:Array, b:Array):int
		{
			if (a[0] >= 0 && b[0] >= 0)
			{
				if (a[0] < b[0])
				{
					return 1;
				}else if (a[0] == b[0])
				{
					return 0;
				}else
				{
					return -1;
				}
			}else if (a[0] >= 0)
			{
				return 1;
			}else if (b[0] >= 0)
			{
				return -1;
			}
			
			if (a[1] > b[1])
			{
				return 1;
			}else if(a[1] == b[1])
			{
				return 0;
			}else
			{
				return -1;
			}
		}
	}

}